package week4.day23;

import java.io.*;

/**
 * @Author fengzihao
 * @Date 2024-05-07 20:39
 */
public class Decode {
    public static void main(String[] args) throws IOException {
        decodeFile(new File("b.txt"),new File("a.txt"));
    }
    public static void decodeFile(File decodingFile, File decodedFile) throws IOException {
        FileInputStream fileInputStream = new FileInputStream(decodingFile);
        FileOutputStream fileOutputStream = new FileOutputStream(decodedFile,true);
        int num = -1;
        while ((num = fileInputStream.read())!=-1){
            if (Character.isDigit(num)){
                if (Character.getNumericValue(num)==0)
                    num = num+9;
                else
                    num = num-1;
            }
            if (Character.isLetter(num)){
                if (num=='a'||num=='A')
                    num+=25;
                else
                    num--;
            }
            fileOutputStream.write(num);
        }
        fileInputStream.close();
        fileOutputStream.close();
    }
}
